<template>
  <div id="energyCenterLeft1">
    <div class="bg-color-black">
      <div class="d-flex pt-2 pl-2">
        <span style="color:#5cd9e8">
          <icon name="chart-bar"></icon>
        </span>
        <div class="d-flex">
          <span class="fs-xl text mx-2">系统实时功率</span>
          <dv-decoration-1 style="width:1.25rem;height:.25rem; position:relative;top:-.0375rem;" />
        </div>
      </div>
      <div class="d-flex jc-center">
        <EnergyCenterLeft1Chart :chart-data="centerData"  />
      </div>
    </div>
  </div>
</template>

<script>
import EnergyCenterLeft1Chart from "_c/energy/energyCenterLeft/energyCenterLeft1Chart";
export default {
  props: {
    chartData: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      centerData:{
        category: [
          "照明",
          "新风",
          "排风",
          "空调",
          "控制器"
        ],
        lineData: [
          0,
          0,
          0,
          0,
          0
        ],
        barData: [
          0,
          0,
          0,
          0,
          0
        ]
      }
    };
  },
  components: {
    EnergyCenterLeft1Chart
  },
  mounted() {},
  methods: {},
  watch: {
    chartData: {
      handler (newData) {
        if (newData !== null && newData.device !== undefined) {
          const device = newData.device
          const category = []
          const ratePower = []
          const power = []
          for (const dev of device) {
            let name = dev.name
            name = name.replace('系统', '')
            name = name.replace('总', '')
            category.push(name)
            ratePower.push(dev.device.ratedPower)
            power.push(dev.power)
          }
          this.centerData = {
            category: category,
            lineData: ratePower,
            barData: power
          }
        }
      },
      immediate: true,
      deep: true
    }
  },
};
</script>

<style lang="scss">
#energyCenterLeft1 {
  padding: 0.2rem;
  height: 5.125rem;
  min-width: 3.75rem;
  border-radius: 0.0625rem;
  .bg-color-black {
    height: 4.8125rem;
    border-radius: 0.125rem;
  }
  .text {
    color: #c3cbde;
  }
  .chart-box {
    margin-top: 0.2rem;
    width: 2.125rem;
    height: 2.125rem;
    .active-ring-name {
      padding-top: 0.125rem;
    }
  }
}
</style>
